package com.vcs.frm.domain;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "clients")
@SuppressWarnings("serial")
public class Client implements java.io.Serializable {

	private Long id = 0L;

	// Company Information
	private String clientName;
	private String clientProfile;
	/* Audit info */
	private Date createdDate;
	private Date updatedDate;

	private Set<Job> jobs = new HashSet<Job>();

	/**
	 * Client is registered to a company(Consultancy) to which we sell our
	 * software So the relationship between client and company will be many to
	 * one, as one company will have many clients registered with it.
	 */
	private Company company;

	// Constructor
	public Client() {

	}

	@Id
	// @GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name = "CLIENT_ID")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "CLIENT_NAME", length = 200, nullable = false)
	public String getClientName() {
		return clientName;
	}

	public void setClientName(String clientName) {
		this.clientName = clientName;
	}

	@Column(name = "PROFILE", length = 4000)
	public String getClientProfile() {
		return clientProfile;
	}

	public void setClientProfile(String clientProfile) {
		this.clientProfile = clientProfile;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "client")
	public Set<Job> getJobs() {
		return jobs;
	}

	public void setJobs(Set<Job> jobs) {
		this.jobs = jobs;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "CREATED_DATE")
	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "UPDATED_DATE")
	public Date getUpdatedDate() {
		return updatedDate;
	}

	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}
	
	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinColumn(name = "COMPANY_ID")
	public Company getCompany() {
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}
	
}